import { tRequest } from "../lib/ts/util"

export const wxlogin = async (obj:{code:string,sf_pid:string | number,xy_pid:string | number })=>{
	let res = await tRequest('post','/api/user/thirdMobileLogin',obj)
	uni.setStorageSync('token',res.data.userinfo.token)
	return res.data.userinfo
}


//获取openid
export const getOpenid = async (code:string)=>{
	return await tRequest('get','openid /api/user/MingetOpenid',{code})
}

//获取用户信息
export const getUserinfoapi = async ()=>{
	let res = await tRequest('get','/api/user/index')
	return res.data
}

//获取系统配置
export const osInfo = async ()=>{
	let res = await tRequest('post','/api/user/OsInfo')
	return res.data
}

//获取轮播图
export const bannerList = async (site:1 | 2)=>{
	let res = await tRequest('get','/api/home.home/banner',{site})
	return res.data
}

//服务详情
export const goodsDetail = async (good_id:number)=>{
	let res = await tRequest('post','/api/homeinfo/GoodsDetail',{good_id})
	return res.data
}

//车辆类型
export const getCarType = async ()=>{
	let res = await tRequest('post','/api/homeinfo/GetCarType')
	return res.data
}

//动力类型
export const getPowerType = async ()=>{
	let res = await tRequest('post','/api/homeinfo/GetCarDlType')
	return res.data
}


//师傅认证申请
interface WorkerAuthentication {
	name:string
	idcard:string
	sfz_a_image:string
	sfz_b_image:string
	jsz_a_image:string
	car_number:string
	car_type:string
	fjs_a_image:string
}
export const applySf = async (form:WorkerAuthentication)=>{
	return await tRequest('post','/api/user/ApplySf',form)
}

//师傅认证信息
export const sfRzInfo = async (user_id:number):Promise<WorkerAuthentication>=>{
	let res = await tRequest('post','/api/user/SfRzInfo',{user_id})
	return res.data
}


//修改用户信息
export const editUserinfo = async (obj:{avatar:string,nickname:string,password?:string})=>{
	return await tRequest('post','/api/user/profile',obj)
}

//获取城市
export const cityDetail = async (name:string)=>{
	let res = await tRequest('post','/api/homeinfo/GetpcaId',{name})
	return res.data
}

//获取省市区
export const getAreaId = async (pid:number)=>{
	let res = await tRequest('post','/api/homeinfo/GetAreaId',{pid})
	return res.data
}

//师傅编辑服务区域
export const editSfServiceQy = async (obj:{service_city_id:number,service_area_ids:string})=>{
	return await tRequest('post','/api/user/EditSfServiceQy',obj)
}

//获取师傅服务区域
export const indexSfServiceQy = async ()=>{
	let res = await tRequest('post','/api/user/IndexSfServiceQy')
	return res.data
}

//新增车辆
export const addCar = async (obj:any)=>{
	return await tRequest('post','/api/user/MyCarAdd',obj)
}

//编辑车辆
export const editCar = async (obj:any)=>{
	return await tRequest('post','/api/user/MyCarEdit',obj)
}


//车辆详情
export const carDetail = async (id:number)=>{
	let res = await tRequest('post','/api/user/MyCarDetail',{id})
	return res.data
}

//设置时间模板
export const setTimeTemplate = async (obj:any)=>{
	return await tRequest('post','/api/master/TimeManage',obj)
}

//获取模板
export const getTimeTemplate = async ()=>{
	let res = await tRequest('post','/api/master/GetTimeManage')
	return res.data
}

//获取师傅时间
export const getSfTime = async (obj:any)=>{
	let res = await tRequest('post','/api/master/GetSfTime',obj)
	return res.data
}

//获取可选优惠券
export const userCoupon = async (good_id:number)=>{
	let res = await tRequest('post','/api/order_info/UserCoupon',{status:0,page:1,limit:1000,good_id})
	return res.data
}

//创建订单
export const createOrder = async (obj:any)=>{
	return await tRequest('post','/api/order_info/Create',obj)
}

//意见反馈
export const suggest = async (obj:any)=>{
	return await tRequest('post','/api/user/Suggest',obj)
}


//获取二维码
export const myQrcode = async (scene:string,is_change:number):Promise<string>=>{
	let res =  await tRequest('post','/api/user/myQrcode',{scene,is_change})
	return  (res.data as string)
}

//获取师傅详情
export const workerDetail = async (user_id:number)=>{
	let res = await tRequest('post','/api/user/SfInfo',{user_id})
	return res.data
}


//订单详情
export const orderDetail = async (order_id:number)=>{
	let res = await tRequest('post','/api/order_info/OrderDetail',{order_id})
	return res.data
}


//助力配置
export const osZl = async ()=>{
	let res = await tRequest('post','/api/order_info/OsZl')
	return res.data
}


//去付款
export const payOrder = async (order_id:number)=>{
	let res = await tRequest('post','/api/order_info/PayOrder',{order_id})
	return res.data
}


//取消订单
export const cancleOrder = async (order_id:number)=>{
	return await tRequest('post','/api/order_info/CancelGoodOrder',{order_id})
}

//订单助力
export const orderZl = async (obj:any)=>{
	return await tRequest('post','/api/order_info/OrderZl',obj)
}


//预约
export const setYyTime = async (obj:any)=>{
	return await tRequest('post','/api/order_info/SetYyTime',obj)
}

//上传合同
export const uploadHt = async (obj:any)=>{
	return await tRequest('post','/api/master/UploadHt',obj)
}


//获取订单数量
export const dfwGetSfTime = async (obj:any)=>{
	let res = await tRequest('post','/api/master/DfwGetSfTime',obj)
	return res.data
}

//核销订单
export const hxOrder = async (order_detail_id:number | string)=>{
	return await tRequest('post','/api/master/HxOrder',{order_detail_id})
}

//更换师傅
export const setPlSf = async (obj:any)=>{
	return await tRequest('post','/api/order_info/SetPlSf',obj)
}

//新增评价
export const orderMark = async (obj:any)=>{
	return await tRequest('post','/api/order_info/OrderMark',obj)
}

//收益数据
export const sfShouyi = async ()=>{
	let res = await tRequest('post','/api/master/SfShouyi')
	return res.data
}


